/**
 * @copyright Copyright (c) 2022 Queclink-C-Library
 * @ingroup common
 * @brief This file is subject to the terms and conditions of the MIT License.
 * For details, please see the LICENSE file or visit the MIT website: https://mit-license.org/
 */

#ifndef QLIBC_CTYPE_H
#define QLIBC_CTYPE_H

#include <ctype.h>
#include <stddef.h>

#ifdef __cplusplus
extern "C" {
#endif

/**
 * @addtogroup ctype
 * @ingroup common
 * @brief Declare by `#include <qlibc/ctype.h>`. Operations related to data type.
 * @{
 */

/**
 * @brief   Test if all characters are decimal digits.
 * @param[in] chars The characters to be checked.
 * @param[in] n     The number of characters.
 * @return  An integer `1` means `yes`, an integer `0` means `no`.
 * @authors Hubert.Lee, Jason.Huang
 * @date    2022/7/7
 */
int quec_aredigits(const char *chars, size_t n);

/**
 * @brief   Splits a byte into two printable characters, such as `0xA8` into character `A` and character `8`.
 * @param[in]  hex  The byte to be split.
 * @param[out] chr1 Pointer to save the first (left, upper) character.
 * @param[out] chr2 Pointer to save the second (right, lower) character.
 * @authors Hubert.Lee, Jason.Huang
 * @date    2022/7/7
 */
void quec_hex2chr(unsigned char hex, char *chr1, char *chr2);

/**
 * @brief   Batch splits a byte into two printable characters, such as `0xA8 0x5D 0x3E` into characters `A85D3E`.
 * @param[in]  phex  The bytes to be split.
 * @param[in]  n     The number of bytes.
 * @param[out] chars Pointer to save the printable characters. Make sure it has enough space.
 * @authors Hubert.Lee, Jason.Huang
 * @date    2022/7/7
 */
void quec_hex2chars(unsigned char *phex, size_t n, char *chars);

/** ctype
 * @}
 */

#ifdef __cplusplus
}
#endif

#endif /* QLIBC_CTYPE_H */
